package game.model;

import game.Utils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.swing.ImageIcon;

/**
 *
 * @author Gab'z
 */
public class Plan {

    public static final Integer NORD = 0;
    public static final Integer EST = 1;
    public static final Integer SUD = 2;
    public static final Integer OUEST = 3;
    private String id;
    private ImageIcon fond;
    private String description;
    private ArrayList<String> objets;
    private ArrayList<String> elementsDecors;
    private ArrayList<String> pnj;
    private ArrayList<String> fous;
    private Fleche[] directions;

    public Plan(String id, String description, ArrayList<String> objets, ArrayList<String> elementsDecors, ArrayList<String> pnj, ArrayList<String> fous) {
        System.out.println("+ Plan : " + id);
        this.id = id;
        if (Utils.mode == Utils.LOCAL) {
            this.fond = new ImageIcon(Utils.baseURLlocal + "fonds\\" + id + Utils.format_img);
        } else {
            try {
                this.fond = new ImageIcon(new URL(Utils.baseURL + "fonds/" + id + Utils.format_img));
            } catch (MalformedURLException ex) {
                System.err.println("Erreur lors de la récupération du fond pour le plan d'id : " + id);
            }
        }

        this.description = description;
        this.objets = objets;
        this.elementsDecors = elementsDecors;
        this.pnj = pnj;
        this.fous = fous;
        Fleche[] fleches = {new Fleche(), new Fleche(), new Fleche(), new Fleche()};
        this.directions = fleches;
    }

    public void setDirection(Integer direction, Boolean actif, String idPlanSuivant) {
        System.out.println("setDirection");
        this.directions[direction].setActif(actif);
        this.directions[direction].setIdPlanSuivant(idPlanSuivant);
    }

    public void activerDirection(Integer direction, Boolean actif) {
        this.directions[direction].setActif(actif);
    }

    public Fleche getFleche(Integer direction) {
        return this.directions[direction];
    }

    public String getId() {
        return id;
    }

    public String getDescription() {
        return description;
    }

    public ArrayList<String> getElementsDecors() {
        return elementsDecors;
    }

    public ImageIcon getFond() {
        return fond;
    }

    public ArrayList<String> getObjets() {
        return objets;
    }

    public ArrayList<String> getPnjs() {
        return pnj;
    }

    public ArrayList<String> getFous() {
        return fous;
    }
}
